package com.tourismhengyang.actions;

import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.tourismhengyang.beans.Ticket;
import com.tourismhengyang.biz.ITicketBiz;
import com.tourismhengyang.impl.TicketBizImpl;
import com.tourismhengyang.utils.JsonObject;

public class TicketAction extends ActionSupport implements ModelDriven<Ticket>{

	private static final long serialVersionUID = 1L;
	private JsonObject json;
	private Ticket ticket;
	private ITicketBiz ticketBiz=new TicketBizImpl();
	public String getTicketList(){
		List<Ticket> list=ticketBiz.getTicketList();
		if(list!=null){
			json=new JsonObject();
			json.setRows(list);
			return SUCCESS;
		}
		return null;
	}
	
	public String addTicketInfo(){
		int result=ticketBiz.addTicketInfo(ticket);
		json=new JsonObject();
		json.setObj(result);
		return SUCCESS;
	}
	
	public String getOneTicket(){
		List<Ticket> list=ticketBiz.getOneTicket(ticket.getLid());
		if(list!=null){
			json=new JsonObject();
			json.setRows(list);
			return SUCCESS;
		}
		return null;
	}
	
	public JsonObject getJson() {
		return json;
	}

	@Override
	public Ticket getModel() {
		if(ticket==null){
			ticket=new Ticket();
		}
		return ticket;
	}
}
